package com.example.demo.staticFiled;

import lombok.Getter;

/**
 * @Author: liull
 * @Description:
 * @Date: Created in 15:31 2020/5/29
 * @Modified By:
 */

public class Demo {
    public static void main(String[] args) {
        Worker w1 = new Worker("Jack");
        w1.startWork();
        System.out.println("当前开工的总人数：" + w1.getTotle());
        Worker w2 = new Worker("Rose");
        w2.startWork();
        System.out.println("当前开工的总人数：" + w2.getTotle());
    }
}

@Getter
class Worker {
    String name;

    /*static*/ int totle = 0;

    public Worker(String name) {
        this.name = name;
    }

    public void startWork() {
        totle++;
        System.out.println("工人：" + this.name + "开工了。");
    }
}